//
//  Connection.h
//  Networking
//  This class includes the low level network communication
//  Provides methods to send NetworkMessages and handles 
//  data callbacks
//
//  Created by Christoph Eßer on 11/24/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "NetworkMessage.h"
#import "NetworkMessageHandler.h"

@interface Connection : NSObject {
@private
    CFSocketRef socketCF;
    id <NetworkMessageHandler> delegate;
    BOOL noError;
}

@property (assign) NSObject<NetworkMessageHandler> *delegate;
@property BOOL noError;

-(id) initWithNativeSocket: (CFSocketNativeHandle) SocketFD;
-(id) initWithRemoteAddress: (NSString*) addr andPort: (NSInteger) port;

-(NSString*) getRemoteAddress;
-(NSInteger) getRemotePort;
-(NSInteger) getLocalPort;
-(BOOL) isAlive;

-(void) sendData:(NSData*)data;
-(void) sendMessage: (NetworkMessage*) msg;
-(void) callBackWithData: (const void*) data;

-(void) sendString: (NSString*) str;
@end
